<template>
  <el-form
    ref="dataFormSatellite"
    :rules="rules"
    :model="temp"
    :label-position="labelPosition"
    :label-width="labelWidth"
    style="margin-left:0px;"
  >
    <el-form-item label="卫星转发器" prop="transponderID">
      <el-select
        ref="transponderID"
        v-model="temp.transponderID"
        class="filter-item"
        clearable
        placeholder="请选择卫星转发器ID"
        :style="'width: ' + width + ';'"
        @click.native="LoadTransponderList"
      >
        <el-option v-for="item in transponderList" :key="item.ID" :label="item.code + '（' + item.name + '）'" :value="item.ID" />
      </el-select>
    </el-form-item>
    <el-form-item label="卫星天线" prop="antennaID">
      <el-select
        ref="antennaID"
        v-model="temp.antennaID"
        class="filter-item"
        clearable
        placeholder="请选择卫星天线ID"
        :style="'width: ' + width + ';'"
        @click.native="LoadAntennaList"
      >
        <el-option v-for="item in antennaList" :key="item.ID" :label="item.name" :value="item.ID" />
      </el-select>
    </el-form-item>
    <el-form-item label="卫星放大器" prop="amplifierID">
      <el-select
        ref="amplifierID"
        v-model="temp.amplifierID"
        class="filter-item"
        clearable
        placeholder="请选择卫星放大器ID"
        :style="'width: ' + width + ';'"
        @click.native="LoadAmplifierList"
      >
        <el-option v-for="item in amplifierList" :key="item.ID" :label="item.code + '（' + item.name + '）'" :value="item.ID" />
      </el-select>
    </el-form-item>
    <el-form-item label="卫星接收机" prop="receiverID">
      <el-select
        ref="receiverID"
        v-model="temp.receiverID"
        class="filter-item"
        clearable
        placeholder="请选择卫星接收机ID"
        :style="'width: ' + width + ';'"
        @click.native="LoadReceiverList"
      >
        <el-option v-for="item in receiverList" :key="item.ID" :label="item.name" :value="item.ID" />
      </el-select>
    </el-form-item>
    <el-form-item label="卫星信标" prop="beaconID">
      <el-select
        ref="beaconID"
        v-model="temp.beaconID"
        class="filter-item"
        clearable
        placeholder="请选择卫星信标ID"
        :style="'width: ' + width + ';'"
        @click.native="LoadBeaconList"
      >
        <el-option v-for="item in beaconList" :key="item.ID" :label="item.name" :value="item.ID" />
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script>
import {
  getAmplifierList,
  getAntennaList,
  getBeaconList,
  getReceiverList,
  getTransponderList
} from '@/api/weixing/base'
import { isNotEmpty } from '@/utils'

export default {
  name: 'ElFormSatellite',
  props: {
    width: {
      type: String,
      default: '330px'
    },
    labelWidth: {
      type: String,
      default: '150px'
    },
    labelPosition: {
      type: String,
      default: 'right'
    },
    satelliteID: {
      type: String,
      default: ''
    },
    temp: {
      type: Object,
      default: null
    },
    rules: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      transponderList: [],
      antennaList: [],
      amplifierList: [],
      receiverList: [],
      beaconList: []
    }
  },
  created() {
    this.LoadList()
  },
  methods: {
    LoadList() {
      this.LoadTransponderList()
      this.LoadAntennaList()
      this.LoadAmplifierList()
      this.LoadReceiverList()
      this.LoadBeaconList()
    },
    LoadTransponderList() {
      if (isNotEmpty(this.satelliteID)) {
        getTransponderList('satelliteID=' + this.satelliteID, 'code'
        ).then(response => {
          this.transponderList = response.body.data.rows
        })
      }
    },
    LoadAntennaList() {
      if (isNotEmpty(this.satelliteID)) {
        getAntennaList('satelliteID=' + this.satelliteID
        ).then(response => {
          this.antennaList = response.body.data.rows
        })
      }
    },
    LoadAmplifierList() {
      if (isNotEmpty(this.satelliteID)) {
        getAmplifierList('satelliteID=' + this.satelliteID, 'code'
        ).then(response => {
          this.amplifierList = response.body.data.rows
        })
      }
    },
    LoadReceiverList() {
      if (isNotEmpty(this.satelliteID)) {
        getReceiverList('satelliteID=' + this.satelliteID
        ).then(response => {
          this.receiverList = response.body.data.rows
        })
      }
    },
    LoadBeaconList() {
      if (isNotEmpty(this.satelliteID)) {
        getBeaconList('satelliteID=' + this.satelliteID
        ).then(response => {
          this.beaconList = response.body.data.rows
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
